import React, { Component } from 'react';
import AboutView from './views/about/AboutView.jsx';
import LoginView from "./views/login/LoginView.jsx"
class App extends Component {
  constructor() {
    super()
    this.state = {
      flag: true
    }
  }
  render() {
    return (
      <div>
        {this.state.flag ? <LoginView /> : <AboutView info={{ uname: 'wqw', uage: 18 }} />}
        <button type='button' onClick={() => {
          this.setState({
            flag: !this.state.flag
          })
        }}>switch Component</button>
      </div>
    )
  }

  // 用于错误回退 UI；
  static getDerivedStateFromError(error) {
    // Update state so the next render will show the fallback UI.
    return { hasError: true };
  }
  // 任何一处的 javascript 报错会触发，用于错误记录；
  componentDidCatch(error, info) {
    // You can also log the error to an error reporting service
    console.log('Error::::', error);
  }
}

export default App;
